 jQuery(function($){
//	var zoom = 1.5;
//	w = $('#portfolio-list img').width();
//	h = $('#portfolio-list img').height();
	
/***********************************************************/
//  Sort 
    var $container = $('#portfolio-list');

 /*   $container.isotope({
        itemSelector : '.element',
		 getSortData : {
			number : function( $elem ) {
            return parseInt( $elem.find('.number').text(), 10 );
			},
			date : function( $elem ) {
            return parseInt( $elem.find('.date').text(), 10 );
			}
		}
      });
 */     
	$('#sort-by a').click(function(){
		var $this = $(this);
		// don't proceed if already selected
		if ( $this.hasClass('selected') ) {
			return false;
        }
		var $sortSet = $this.parents('.sort-set');
        $sortSet.find('.selected').removeClass('selected');
        $this.addClass('selected');
		
		// get href attribute, minus the '#'
		var sortName = $(this).attr('href').slice(1);
		$container.isotope({ sortBy : sortName, sortAscending : false });
	    return false;
	});


 /***********************************************************/
//  filter 
     
    $('#portfolio-filter a').click(function(){
        var $this = $(this);
        // don't proceed if already selected
        if ( $this.hasClass('selected') ) {
          return false;
        }
        var $optionSet = $this.parents('.option-set');
        $optionSet.find('.selected').removeClass('selected');
        $this.addClass('selected');
  
        // make option object dynamically, i.e. { filter: '.my-filter-class' }
        var options = {},
            key = $optionSet.attr('data-option-key'),
            value = $this.attr('data-option-value');
        // parse 'false' as false boolean
        value = value === 'false' ? false : value;
        options[ key ] = value;
        if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
          // changes in layout modes need extra logic
          changeLayoutMode( $this, options )
        } else {
          // otherwise, apply new options
          $container.isotope( options );
        }
        
        return false;
    });      
});